<?php
/**
 * @author andycao
* 发送失败的邮件进行重发送
* */
apf_require_class('Oa_Job_Attendance_Abstract');
apf_require_class('Tools_SendMail');
apf_require_class('Bll_Attendance_EmailLog');
class Oa_Job_Attendance_SendLoopEmail extends Oa_Job_Attendance_Abstract {

    /** 考勤系统读 **/
    private $readdb = "attendance_slave";
    /** 考勤系统写 **/
    private $writedb = "attendance_master";

    public function run(){

        $bll = new Bll_Attendance_EmailLog();
        $email_list = $bll->get_list();
        if(empty($email_list)){
            $this->log("Not Found Email To Send");exit;
        }
        foreach($email_list as $val){
            Tools_SendMail::get_instance()->set_mail_hash($val['hash_str']);
            Tools_SendMail::get_instance()->send($val['to_email'], $val['title'], $val['body']);
            $this->log("Send ".$val['hash_str']." ==".$val['to_email']."==".$val['title']."..");
            sleep(3);// stop 3 sec
        }
        $this->log(date('Y-m-d H:i:s')."Done");
    }
}